$(function(){
	
	// 浏览量,滚动到那一条就算浏览一次
	var $view=$(".views");
	var view_times=$view.text();
	var hasView=false;
	var viewtop=$view.offset().top;
	$(window).scroll(function(e){
		if (e.pageY>=viewtop) {
			if (!hasView){
				view_times++;
				hasView=true;
			}
		}
	})
	
	
});
function changeData(val){
    val=val.replace(/\s{2,}|\<br\s*\/\>/g,' ')		//超过两个空字符或者是<br></br>都替换成空格
	return val;
}
function setHot(data,$demo){
	if (data.photo) {
		$demo.find(".user-pic img").attr("src",data.photo);
	}else{
		$demo.find(".user-pic img").attr("src","<?=Url::to('@web/images/default.jpg');?>");
	}
	$demo.find(".user-id").text(data.name);
	$demo.find(".user-date").text(data.comment_time);
	$demo.find(".views").text(data.play_num);
	$demo.find(".goods").text(data.like_num);
    $demo.find(".user-comments").html(changeText(changeData(data.comment_content)));
    var tx=$demo.find(".user-comments").text();
    var $cmts=$demo.find(".user-comments");
    var removetx='';
    if ($cmts.find(".selfText")) {
    	removetx=$demo.find(".user-comments").find(".selfText").text();
    }
    tx=tx.replace(removetx,'');
    $demo.find(".user-comments").text(changeText(tx));
	var likepeo=data.like_ids;
	if (likepeo.indexOf(current_userid)!=-1&&likepeo.length>0) {
		$demo.find(".good-times>span").addClass("isgood");
	}
}